<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var ary = [1, 2, 3, 4];

        function fn(ary) {
            ary[0] = 0; // 全局的和函数的ary = [0,2,3,4]
            ary = [0]; //函数中的ary = [0]
            ary[0] = 100; //函数的ary[0] = 100
            return ary; //返回函数的ary
        }
        var res = fn(ary);
        console.log(ary); // [0,2,3,4]
        console.log(res); // [100]
    </script>
</body>

</html>